 package com.gmrz.uaf.db;

 import com.gmrz.uaf.common.UAFRuntimeException;
 import org.apache.commons.dbcp2.BasicDataSourceFactory;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;

 import javax.naming.Context;
 import javax.naming.Name;
 import java.util.Hashtable;
 
 public class UAFDataSourceFactory extends BasicDataSourceFactory
 {
   private static final Logger LOG = LogManager.getLogger(UAFDataSourceFactory.class);

   public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment)
   {
     try
     {
       return super.getObjectInstance(obj, name, nameCtx, environment);
     } catch (Exception ex) {
       LOG.error("Unexpected error while trying to get connection using datasource.", ex);
       throw new UAFRuntimeException("Unexpected error while trying to get connection using datasource.", ex);
     }
   }
 
 }
